package com.test.demo;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/05/22 10:45
 **/
interface Network {
    void browse();
}

class Real implements Network {

    @Override
    public void browse() {
        System.out.println("上网浏览信息！");
    }

    public void game() {
        System.out.println("play game");
    }
}

class Proxy implements Network {
    private Network network;

    public Proxy(Network network) {
        this.network = network;
    }

    public void check() {
        System.out.println("检查上网用户身份是否合法！");
    }

    public void browse() {
        this.check();
        this.network.browse();
        ((Real) network).game();
    }
}

public class PeoxyDemo1 {
    public static void main(String[] args) {
        Network proxy = new Proxy(new Real());
        proxy.browse();
    }
}
